import request from '@/utils/request'

export function addOrder(data) {
  return request({
    url: 'api/logistics/addOrder',
    method: 'post',
    data
  })
}

export function queryDestInfo(orderNo) {
  return request({
    url: 'api/logistics/queryDestInfo?orderNo=' + orderNo,
    method: 'get'
  })
}

export function queryOrder(orderNo) {
  return request({
    url: 'api/logistics/queryOrder?orderNo=' + orderNo,
    method: 'get'
  })
}

export function queryLogistics(orderNo) {
  return request({
    url: 'api/logistics/queryLogistics?orderNo=' + orderNo,
    method: 'get'
  })
}

export function queryLazyTree(parentCode) {
  return request({
    url: 'api/region/lazy-tree?parentCode=' + parentCode,
    method: 'get'
  })
}

export function cancelThirdOrder(bspOrderNo) {
  return request({
    url: 'api/logistics/cancelThirdOrder?logisticsId=' + bspOrderNo,
    method: 'get'
  })
}

export function queryLogisticsById(id) {
  return request({
    url: 'api/logistics/queryLogisticsById?logisticsId=' + id,
    method: 'get'
  })
}

export function update(data) {
  return request({
    url: 'api/logistics/update',
    method: 'post',
    data
  })
}

export function updateFlag(data) {
  const { flag, orderId } = data
  return request({
    url: `api/logistics/updateFlag?flag=${flag}&orderId=${orderId}`,
    method: 'post'
  })
}
